import { Link, useLocalSearchParams } from 'expo-router'; import { ActivityIndicator, Pressable, ScrollView, StyleSheet, Text, View, } from 'react-native'; import { useOffice } from '@/features/offices/hooks/useOffice'; import { useFavoriteOffices } from '@/features/offices/hooks/useFavoriteOffices'; import theme from '@/theme'; import { Feather, MaterialIcons } from '@expo/vector-icons'; export default function OfficeDetailScreen() { const params = useLocalSearchParams<{ officeId: string }>(); const officeId = typeof params.officeId === 'string' ? params.officeId : undefined; const { office, loading, error, reload } = useOffice(officeId); const { favoriteOfficeIdsSet, pendingOfficeId, toggleFavorite, } = useFavoriteOffices(); if (loading) { return ( ); } if (error || !office) { return ( {error ?? 'No se pudo cargar el espacio'} Reintentar Volver ); } const isFav = favoriteOfficeIdsSet.has(office.id); const isAvailable = office.available ?? true; return ( {/* HEADER */} ← Volver a espacios {/* IMAGE */} {/* 🏢 */} {/* TITLE */} {office.name} {office.location ?? 'Sin ubicación'} {isAvailable ? 'Disponible' : 'Ocupado'} {/* CAPACITY + PRICE */} {office.capacity} personas {/* {office.price ?? '—'} */} {/* DESCRIPTION */} {office.description && ( Descripción {office.description} )} {/* FAVORITE */} toggleFavorite(office.id)} disabled={pendingOfficeId === office.id} > {pendingOfficeId === office.id ? '...' : isFav ? '★ Guardado' : '☆ Guardar como favorito'} {/* RESERVE BUTTON */} Reservar ahora ); } const styles = StyleSheet.create({ container: { paddingVertical: theme.spacing.xl, }, content: { width: '100%', maxWidth: theme.layout.contentWidth, alignSelf: 'center', paddingHorizontal: theme.spacing.xl, gap: theme.spacing.xl, }, center: { flex: 1, justifyContent: 'center', alignItems: 'center', padding: theme.spacing.xl, gap: theme.spacing.md, }, back: { color: theme.colors.textSecondary, fontSize: theme.typography.md, }, imageBox: { width: '100%', height: 180, borderRadius: theme.radius.xl, backgroundColor: theme.colors.primarySoft, alignItems: 'center', justifyContent: 'center', }, imageIcon: { fontSize: 48, }, titleRow: { flexDirection: 'row', justifyContent: 'space-between', alignItems: 'flex-start', gap: theme.spacing.md, }, title: { fontSize: theme.typography.xxxl, fontWeight: theme.fontWeight.semibold, color: theme.colors.text, }, subtitle: { color: theme.colors.textSecondary, marginTop: 4, }, metaRow: { flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', }, meta: { color: theme.colors.textSecondary, }, price: { color: theme.colors.primary, fontSize: theme.typography.xxl, fontWeight: theme.fontWeight.semibold, }, card: { backgroundColor: theme.colors.surface, borderRadius: theme.radius.lg, padding: theme.spacing.lg, borderWidth: 1, borderColor: theme.colors.border, ...theme.shadows.card, }, sectionTitle: { fontSize: theme.typography.lg, fontWeight: theme.fontWeight.semibold, marginBottom: theme.spacing.sm, color: theme.colors.text, }, text: { color: theme.colors.textSecondary, }, badge: { backgroundColor: theme.colors.divider, paddingHorizontal: theme.spacing.md, paddingVertical: theme.spacing.xs, borderRadius: theme.radius.sm, }, badgeActive: { backgroundColor: theme.colors.successBg, }, badgeText: { color: theme.colors.textSecondary, fontSize: theme.typography.sm, }, badgeTextActive: { color: theme.colors.successText, }, favoriteButton: { padding: theme.spacing.md, borderRadius: theme.radius.md, backgroundColor: theme.colors.divider, alignItems: 'center', }, favoriteButtonActive: { backgroundColor: '#ffe8a3', }, favoriteText: { fontWeight: theme.fontWeight.medium, color: theme.colors.text, }, reserveButton: { backgroundColor: theme.colors.primary, paddingVertical: theme.spacing.lg, borderRadius: theme.radius.lg, alignItems: 'center', }, reserveText: { color: theme.colors.white, fontWeight: theme.fontWeight.semibold, fontSize: theme.typography.lg, }, primaryButton: { backgroundColor: theme.colors.primary, padding: theme.spacing.md, borderRadius: theme.radius.md, }, primaryButtonText: { color: theme.colors.white, fontWeight: theme.fontWeight.semibold, }, secondaryButton: { backgroundColor: theme.colors.muted, padding: theme.spacing.md, borderRadius: theme.radius.md, }, });